package com.lk.springboot.dao;

import com.lk.springboot.vo.TheSiteSP;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author lk
 * @date 2020/1/10 0010 18:49
 */
@Mapper
public interface SitesPhotoMapper {
    // 取出用户某一特定站点的，拥有的拼图碎片 id + url + tags
    @Select("select distinct u_s_have.sp_id, url ,tags  from u_s_have,smallphoto where u_id=#{u_id} and s_id=#{s_id} and u_s_have.sp_id=smallphoto.sp_id")
    List<TheSiteSP> getAllSP(@Param("u_id") String u_id, @Param("s_id") String s_id);

    //取出指定站点下的未拥有的拼图碎片的 id + url + tags
    @Select("select smallphoto.sp_id ,url,tags from smallphoto,photo,sites where tags=#{tags} and s_id=#{s_id} and smallphoto.sp_id=photo.sp_id and photo.p_id=sites.p_id ")
    TheSiteSP getMySP(@Param("tags") int tags, @Param("s_id") String s_id);

    // 获取 指定用户， 某一特定站点，其中一块拼图，已经获得的数量
    @Select("select count(*) from u_s_have where u_id=#{u_id} and s_id=#{s_id} and sp_id=#{sp_id}")
    int getTheSmallPhoto(@Param("u_id") String u_id, @Param("s_id") String s_id, @Param("sp_id") String sp_id);

}
